home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_061 / lpatch / lpatch.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  80 lines

  1. /*
  2.  * LPatch.c - C. Scheppner  03/87
  3.  *
  4.  *    Corrects the startup code of some 1.0/1.1 programs such as
  5.  *    Atom so that they don't abort during startup with the Alert
  6.  *    00038007. (can't open dos library).  The problem is caused
  7.  *    by d0 (version) being uninitialized prior to the OpenLibrary.
  8.  *
  9.  *   LINKAGE INFO:
  10.  *     Compile with -v flag on LC2
  11.  *     Link with AStartup.obj ... LIBRARY Amiga.lib, LC.lib
  12.  */
  13.  
  14. #include <exec/types.h>
  15. #include <libraries/dos.h>
  16. #include <libraries/dosextens.h>
  17.  
  18. /* Patch Offsets, Old Values, New Values */
  19.  
  20. ULONG  offset[] = {0x196,0x197, 0x213, 0x23E,0x23F,0x240,0x241,0x242,0x243};
  21. UBYTE  oldval[] = {0x01, 0x4E,  0xD2,  0x24, 0x3C, 0x00, 0x00, 0x03, 0xED};
  22. UBYTE  newval[] = {0x00, 0xA8,  0x2C,  0x70, 0x00, 0x60, 0x00, 0x00, 0xA2};
  23.  
  24. LONG file;
  25.  
  26. main(argc, argv)
  27. int argc;
  28. char **argv;
  29.    {
  30.    LONG            rLen, wLen;
  31.    char            *filename;
  32.    UBYTE  buf[4];
  33.    int k;
  34.  
  35.    if (argc==0) cleanexit("");
  36.    if ((argc==1)||(argc>2)||(*argv[1]=='?'))
  37.       cleanexit("Usage: LPatch filename");
  38.  
  39.    filename = argv[1];
  40.  
  41.    if(!(file = Open(filename, MODE_OLDFILE)))
  42.       cleanexit("File not found");
  43.  
  44.    for(k=0;k<9;k++)
  45.       {
  46.       Seek(file,offset[k],OFFSET_BEGINING);
  47.       if((rLen = Read(file,buf,1)) < 1)  cleanexit("Read error");
  48.       if(buf[0] != oldval[k])  cleanexit("File not correct for patch");
  49.       }
  50.  
  51.    for(k=0;k<9;k++)
  52.       {
  53.       Seek(file,offset[k],OFFSET_BEGINING);
  54.       if((wLen = Write(file,&newval[k],1)) < 1)  cleanexit("Write error");
  55.       }
  56.  
  57.    cleanup();
  58.    }
  59.  
  60.  
  61. cleanexit(s)
  62.    char  *s;
  63.    {
  64.    if (*s)
  65.       {
  66.       printf("%s \n",s);
  67.       }
  68.    cleanup();
  69.    exit();
  70.    }
  71.  
  72. cleanup()
  73.    {
  74.    if(file)  Close(file);
  75.    }
  76.  
  77. /* end */
  78.  
  79.  
  80.